<template>
	<view class="WQook">
		<view class="header">
			
		</view>
		<view class="wqSum">
			<!-- 总错题书 -->
			<view class="sum">
				{{sum}}
			</view>
			<view class="sum-text">
				总错题数
			</view>
			<!-- 错题列表 -->
			

		</view>
		<view class="wqList">
			<view class="wqList-s" v-for="item in dataList" :key="item.id" @click="gotoWQCorrection(item)">
				<view class="topic">
					<text>{{item.indexs}}.</text>
					<text class="topic-content">{{item.question}}</text>
				</view>
				<view class="op-content">
					<text>我选择:</text>
					<text class="options">{{item.user_question_select}}</text>
					<text class="woring">错</text>
				</view>
			</view>
		</view>
		<!-- <view class="footer">
			<image class="footerimg" src="https://wlsy.nanjingyunpeng.cn/weixin/image/footerImg.png"></image>
		</view> -->
	</view>
</template>

<script>
	import {
		wrongBook
	} from "../../api/api.js"
	export default {
		data() {
			return {
				sum:0,
				indexS:0,
				dataList: [],
				routerType:"",
			}
		},
		onLoad(option){
			console.log("option",option)
			this.routerType = option.type
			this.wrongBook()
		},
			
		onBackPress(e){
			console.log("222222222",e)
		},
		onUnload() {
		
			console.log("this.type",this.routerType)
			if(this.routerType=="home"){
				uni.switchTab({
					url: '/pages/home/home'
				})
			}else{
				uni.switchTab({
					url: '/pages/center/center'
				})
			}
		},
		
		
		methods:{
			async wrongBook(){
				let res = await wrongBook()
				if(res.code==1000){
					console.log("wrongBookwrongBook",res)
					this.sum = res.data.length
					res.data.forEach((item,index)=>{
						this.dataList.push({
							indexs:index+1,
							answer:item.answer,
							id: item.id,
							optiona: item.optiona,
							optionb: item.optionb,
							optionc: item.optionc,
							optiond: item.optiond,
							qid: item.qid,
							question:item.question,
							user_question_select: item.user_question_select,
						})
					})
					
				}
			},
			gotoWQCorrection(val){
				// const correctionData = JSON.stringify(val)
				// console.log("correctionData",val)
				console.log("correctionData",val.id,val.qid)
				uni.navigateTo({
					url: `/pages/problem/WQCorrection?id=${val.id}&qid=${val.qid}`
				});
			},
			

		}

	}
</script>

<style scoped lang="scss">
	.WQook {
		
		min-height: 100%;
		background-color: #EEF7FE;
		padding: 30rpx;
		padding-top: 70rpx;
		box-sizing: border-box;
		.header{
			width: 750rpx;
			height: 40rpx;
			background:#466EE7 ;
			border-radius: 0rpx 0rpx 60rpx 60rpx;
			position: fixed;
			top: 0;
			left: 0;
		}

		.wqSum {
			width: 690rpx;
			height: 224rpx;
			background: #FFFFFF;
			box-shadow: 0px 2rpx 8rpx 0px rgba(51, 51, 51, 0.05);
			border-radius: 15px 15px 15px 15px;
			opacity: 1;
			text-align: center;
			padding-top: 40rpx;
			box-sizing: border-box;
			z-index: 999;

			.sum {
				font-size: 90rpx;
				font-family: DIN-Bold, DIN;
				font-weight: bold;
				color: #CA1313;
				line-height: 106rpx;
			}

			.sum-text {
				font-size: 32rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 38rpx;
			}
		}
		.wqList{
			.wqList-s{
				width: 690rpx;
				height: auto;
				background: #FFFFFF;
				box-shadow: 0px 2rpx 8rpx 0px rgba(51, 51, 51, 0.05);
				border-radius: 15px 15px 15px 15px;
				opacity: 1;
				visibility: 1;
				margin-top: 20rpx;
				padding: 30rpx;
				box-sizing: border-box;
				.topic{
					font-size: 30rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #333333;
					line-height: 36rpx;
					text-align: left;
					.topic-content{
						margin-left: 10rpx;
					}
				}
				.op-content{
					font-size: 32rpxpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 38rpx;
					text-align: left;
					margin-top: 20rpx;
					.options{
						margin: 0 30rpx;
					}
					.woring{
						font-size: 32rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #CA1313;
						line-height: 38px;
					}
				}
			}
		}
		.footer {
			width: 750rpx;
			height: 324rpx;
			position: fixed;
			bottom: 0;
			left: 0;
		
			.footerimg {
				width: 100%;
				height: 100%;
			}
		}
	}
</style>
